import { httpGet, httpPost } from "../utils/http";
const apiUrl = "tykb";

/**
 * 托育看板-营收统计
 * @param {*} param
 * @returns
 */
export function revenueStatisticsYear(param) {
  // 全年
  // return httpPost(`${apiUrl}/revenueStatisticsYear`, param)
  //   .then((r) => r?.[0]?.data)
  //   .then((t) => t.records?.[0]);
  const d = new Date();
  const year = d.getFullYear();
  const month = d.getMonth() + 1;
  const p = { year, month };
  // 当月
  return httpPost(`${apiUrl}/revenueStatistics`, p)
    .then((r) => r?.[0]?.data)
    .then((t) => t.records?.[0]);
}

/**
 * 托育看板-各园收支情况
 * @param {*} param
 * @returns
 */
export function childcareIncomeExpenditure(param) {
  return httpPost(`${apiUrl}/childcareIncomeExpenditure`, param)
    .then((r) => r?.[0]?.data)
    .then((t) => t.records);
}

/**
 * 托育看板-托育人数统计
 * @param {*} param
 * @returns
 */
export function peopleCounting(param) {
  return httpPost(`${apiUrl}/peopleCounting`, param)
    .then((r) => r?.[0]?.data)
    .then((t) => t.records?.[0]);
}

/**
 * 托育看板-各园托育情况
 * @param {*} param
 * @returns
 */
export function chidcareSituation(param = {}) {
  return httpPost(`${apiUrl}/chidcareSituation`, param)
    .then((r) => r?.[0]?.data)
    .then((t) => t.records);
}

/**
 * 托育看板-在园幼儿时长
 * @param {*} param
 * @returns
 */
export function durationChildcare(param = {}) {
  return httpPost(`${apiUrl}/durationChildcare`, param)
    .then((r) => r?.[0]?.data)
    .then((t) => t.records);
}

/**
 * 托育看板-托育分布图
 * @param {*} param
 * @returns
 */
export function childcareDistribution(param = {}) {
  return httpPost(`${apiUrl}/childcareDistribution`, param)
    .then((r) => r?.[0]?.data)
    .then((t) => t.records);
}
